package com.atguigu.yygh.oss.controller.front;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.oss.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * Created with IntelliJ IDEA
 *
 * @Date: 2023/1/3 - 16:54
 * @Author: Hyoung
 * @Description:
 */

@Api(tags = "阿里云文件管理")
@RestController
@RequestMapping("/front/oss/file")
public class FrontFileController {

    @Autowired
    private FileService fileService;

    /**
     * 文件上传
     */
    @ApiOperation("文件上传")
    @PostMapping("/upload")
    public R upload(MultipartFile file) {

        String uploadUrl = fileService.upload(file);
        return R.ok().message("文件上传成功").data("url", uploadUrl);
    }
}